using System;
using CStock;

namespace CStock
{
	
	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
	public class TradeCondition : ITradeCondition //
	{

		#region private fields

		private string  buyOrSell; // Buy or Sell
		private string  andOrOr ;// True if AND, False if OR
		
	
		private int period;
		private int periodIndicator2;


		private string indicatorName;
		private string greaterOrLess; // If Buy: True if >; False if =; Sell: True if <
		

		private string thresholdValueOrIndicator;
	
		private double optimizeStart;
		private double optimizeEnd;
		private double optimizeStep ;

		private bool thresholdIsIndicator;

    
		#endregion

		#region constructor, dispose

		public TradeCondition()
		{
			buyOrSell = "Buy";
			andOrOr = "And";
            indicatorName = "MovingAverageExponential";
			period = 10;
			periodIndicator2 = 10;
			greaterOrLess = ">"; // If Buy: True if >; False if =; Sell: True if <
			thresholdValueOrIndicator = "1";
			optimizeStart= 0;
            optimizeEnd = 12;
			optimizeStep = 10;
			
		}
        public ITradeCondition Copy()
        {
            ITradeCondition tc = new TradeCondition();
            tc.BuyOrSell = this.buyOrSell;
            tc.AndOrOr = this.andOrOr;
            tc.IndicatorName = this.indicatorName;
            tc.Period = this.period;
            tc.PeriodIndicator2 = this.periodIndicator2;
            tc.GreaterOrLess = this.greaterOrLess;
            tc.ThresholdValueOrIndicator = this.thresholdValueOrIndicator;
            tc.OptimizeStart = this.optimizeStart;
            tc.OptimizeEnd = this.optimizeEnd;
            tc.OptimizeStep = this.optimizeStep;
            return tc;


        }
		#endregion

		#region public properties

		public string BuyOrSell 
		{
			get
			{
				return buyOrSell;
			}
			set
			{
				buyOrSell = value;
			}
		}
		public string AndOrOr 
		{
			get
			{
				return andOrOr;
			}
			set
			{
				andOrOr = value;
			}
		}
		public string IndicatorName 
		{
			get
			{
				return indicatorName;
			}
			set
			{
				indicatorName = value;
			}
		}
		public int Period 
		{
			get
			{
				return period;
			}
			set
			{
				period = value;
			}
		}
		public int PeriodIndicator2 
		{
			get
			{
				return periodIndicator2;
			}
			set
			{
				periodIndicator2 = value;
			}
		}
		

		public string GreaterOrLess 
		{
			get
			{
				return greaterOrLess;
			}
			set
			{
				greaterOrLess = value;
			}
		}
		public string ThresholdValueOrIndicator 
		{
			get
			{
				return thresholdValueOrIndicator;
			}
			set
			{
				thresholdValueOrIndicator = value;
			}
		}
		public bool ThresholdIsIndicator
		{
			get
			{
				return thresholdIsIndicator;
			}
			set
			{
				thresholdIsIndicator = value;
			}
		}
		

		public double OptimizeStart 
		{
			get
			{
				return optimizeStart;
			}
			set
			{
				optimizeStart = value;
			}
		}
		
		public double OptimizeEnd 
		{
			get
			{
				return optimizeEnd;
			}
			set
			{
				optimizeEnd = value;
			}
		}
		public double OptimizeStep 
		{
			get
			{
				return optimizeStep;
			}
			set
			{
				optimizeStep = value;
			}
		}
		#endregion

	}
}
